<?php /* 程序侠版权所有 技术论坛支持: bbs.chengxuxia.com QQ: 573907419 正版授权防止出现漏洞后门
-- enphp : https://git.oschina.net/mz/mzphp2
 */

namespace app\common\model;
error_reporting(E_ALL ^ E_NOTICE);
use think\Model;

class Config extends Model
{
    static private function _config($var_1)
    {
        $var_3 = ['site_config' => 1, 'system_config' => 2, 'seo_config' => 3, 'api_config' => 4, 'oauth_config' => 5, 'score_config' => 6,];
        return $var_3[$var_1];
    }

    public function webConfig($var_4)
    {
        $var_6 = [];
        $var_7['type'] = self::_config($var_4);
        $var_8 = self::where($var_7)->field('name,value')->select();
        if ($var_8 && is_array($var_8)) {
            foreach ($var_8 as $var_9) {
                $var_6[$var_9['name']] = json_decode($var_9['value']) ? json_decode($var_9['value'], !0) : $var_9['value'];
            }
            cache($var_4, $var_6);
        }
    }

    static public function updateCofig($var_10, $var_11, $var_12)
    {
        $var_12 = is_array($var_12) ? json_encode($var_12) : $var_12;
        $var_14 = ['name' => $var_10, 'type' => self::_config($var_11)];
        if (self::where($var_14)->find()) {
            $var_15 = self::where($var_14)->update(['value' => $var_12]);
        } else {
            $var_16 = ['type' => $var_11, 'name' => $var_10, 'value' => $var_12];
            $var_15 = self::create($var_16);
        }
        cache($var_11, null);
        if ($var_15) {
            return !0;
        } else {
            return !1;
        }
    }
}

;;;;